package com.smile.frame.alibaba.services.gateway;

import com.smile.frame.alibaba.services.gateway.gray.CustomServiceInstanceListSupplierConfiguration;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient;
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @author LGC
 * @date 2021/12/6 17:38
 */
@Slf4j
@EnableDiscoveryClient
@SpringBootApplication(scanBasePackages = "com.smile.frame")
@LoadBalancerClients({@LoadBalancerClient(value = "frame-alibaba-services-order", configuration = CustomServiceInstanceListSupplierConfiguration.class)})
//@LoadBalancerClients(defaultConfiguration = GlobalServiceInstanceListSupplierConfiguration.class)
public class AlibabaGatewayServiceApplication {
    public static void main(String[] args) throws UnknownHostException {
        SpringApplication app = new SpringApplication(AlibabaGatewayServiceApplication.class);
        ConfigurableApplicationContext run = app.run(args);
        Environment env = run.getEnvironment();
        log.info("\n----------------------------------------------------------\n\t" +
                        "启动成功\n\t" +
                        "应用 '{}' 正在运行! 链接地址为:\n\t" +
                        "本地地址: \thttp://localhost:{}\n\t" +
                        "网络地址: \thttp://{}:{}\n\t" +
                        "----------------------------------------------------------",
                env.getProperty("spring.application.name"),
                env.getProperty("server.port"),

                InetAddress.getLocalHost().getHostAddress(),
                env.getProperty("server.port"));
    }
}
